<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>会员登录</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
		<link rel="stylesheet" href="../css/mint-ui.css" />
		<link rel="stylesheet" href="../css/animate.css" />
		<link rel="stylesheet" href="../css/main.css" />
	</head>
	<body>
		<div id="app">
			<img src="../images/logo.jpg" width="100%"/>
			<mt-field label="用户名" placeholder="请输入用户名/手机号" 
				v-model="username" :attr="{maxlength:11}"></mt-field>
			<mt-field label="密码" placeholder="请输入密码"  
				type="password" v-model="password" :attr="{maxlength:20}"></mt-field><br />
			<mt-button type="primary" size="large" @click="login">登 录</mt-button>
			
			<p class="goRegister">
				<span @click="forgetPass">忘记密码？</span>还没有账号？现在马上
				<strong @click="goRegister">去注册</strong>
			</p>
			
			<p class="vipLogins" @click="goVipLogin">柜台办理会员充值的请点击此处去登录</p>
			
		</div>
	</body>
	<script type="text/javascript" src="../js/rem.js" ></script>
	<script type="text/javascript" src="../js/vue.js" ></script>
	<script type="text/javascript" src="../js/mint-ui.js" ></script>
	<script type="text/javascript" src="../js/axios.min.js" ></script>
	<script>
		var openId=location.search.substring(8);
		localStorage.setItem("openId",openId);//缓存openId
		new Vue({
			el:"#app",
			data:{
				username:"",
				password:""
			},
			created(){
				
			},
			methods:{
				//忘记密码
				forgetPass:function(){
					location.href="forgetPw.html";
				},
				//登录
				login:function(){
					var passReg=/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/;
					if(this.username==""){
						this.$toast("请输入您的用户名");return;
					}else if(this.passwords == "" || !passReg.test(this.password)){
						this.$toast("请输入6-20位数字字母组合密码");return;
					}
					axios.post('http://106.13.55.49/api/jdUser/login',{
						"phone":this.username,
						"password":this.password,
						"openId":openId
					}).then(data => {
							console.log(data);
							if(data.data.status == 200){
								location.href="vip.html?openId="+openId;
							}else{
								this.$toast(data.data.message);return;
							}
					})
				},
				//去注册
				goRegister:function(){
					location.href="register.html";
				},
				//VIP登录
				goVipLogin:function(){
					location.href="vipLogin.html?openId="+openId;
				}
			}
			
		})
	</script>
</html>
